const express = require('express');
const router = express.Router();
const sql = require("../db/index")
const Response = require("../utils/Response");

//获取学生单词学习情况数据
router.get('/word', async (req, res) => {
    const [response] = await sql.query("select * from s_wordstudy")
    //将获取的数据去掉双引号
    response.forEach(item => {
        item.sales = JSON.parse(item.sales);
    })
    res.send(new Response(200,"获取成功",response))
})

//获取学生考试成绩均分数据
router.get('/score', async (req, res) => {
    const [response] = await sql.query("select * from s_score")
    //将获取的数据去掉双引号
    response.forEach(item => {
        item.sales = JSON.parse(item.sales);
    })
    res.send(new Response(200,"获取成功",response))
})

//获取学生完成作业情况数据
router.get('/homework', async (req, res) => {
    const [response] = await sql.query("select * from s_homework")
    //将获取的数据去掉双引号
    response.forEach(item => {
        item.value = JSON.parse(item.value);
    })
    res.send(new Response(200,"获取成功",response))
})
module.exports = router;